import { BasicLayout } from '@/layouts'
import LoginLayout from '@/views/tmall/layout/LoginLayout'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view')
}

export const asyncRouterMap = [

  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: 'menu.home' },
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('@/views/tmall/home'),
        meta: { title: '首页', keepAlive: false, icon: 'appstore' }
      },
      {
        path: '/homeDetail',
        name: 'homeDetail',
        component: () => import('@/views/tmall/homeDetail'),
        meta: { title: '店铺概况', keepAlive: false, icon: 'bank' }
      },
      {
        path: '/system',
        name: 'System',
        component: RouteView,
        meta: { title: '系统管理', keepAlive: true, icon: 'setting', permission: ['teacher'] },
        children: [
          {
            path: '/system/user/userManage',
            name: 'UserManage',
            meta: { title: '用户管理', keepAlive: true, icon: 'user', permission: ['teacher'] },
            component: () => import('@/views/tmall/system/user/UserManage')
          }
        ]
      },
      {
        path: '/product',
        name: 'product',
        redirect: '/product/createProduct',
        component: RouteView,
        meta: { title: '商品', icon: 'shopping' },
        children: [
          {
            path: '/product/createProduct',
            name: 'CreateProduct',
            component: () => import('@/views/tmall/product/createProduct'),
            meta: { title: '创建商品', keepAlive: true }
          },
          {
            hidden: true,
            path: '/product/detailProduct',
            name: 'DetailProduct',
            component: () => import('@/views/tmall/product/detailProduct'),
            meta: { title: '商品详细', keepAlive: true }
          },
          {
            hidden: true,
            path: '/product/updateProduct',
            name: 'UpdateProduct',
            component: () => import('@/views/tmall/product/updateProduct'),
            meta: { title: '商品修改', keepAlive: true }
          },
          {
            hidden: true,
            path: '/product/previewProduct',
            name: 'PreviewProduct',
            component: () => import('@/views/tmall/product/previewProduct'),
            meta: { title: '商品预览', keepAlive: true }
          },
          {
            path: '/product/manageProduct',
            name: 'ManageProduct',
            component: () => import('@/views/tmall/product/manageProduct'),
            meta: { title: '商品管理', keepAlive: true }
          }
        ]
      },

      {
        path: '/order',
        name: 'order',
        component: RouteView,
        redirect: '/order/manageOrder',
        meta: { title: '订单', icon: 'profile' },
        children: [
          {
            path: '/order/manageOrder',
            name: 'ManageOrder',
            component: () => import('@/views/tmall/order/manageOrder'),
            meta: { title: '订单管理', keepAlive: true }
          },
          {
            path: '/order/manageEvaluate',
            name: 'ManageEvaluate',
            component: () => import('@/views/tmall/order/manageEvaluate'),
            meta: { title: '评价管理', keepAlive: true }
          },
          {
            path: '/order/batchSend',
            name: 'BatchSend',
            component: () => import('@/views/tmall/order/batchSend'),
            meta: { title: '批量发货', keepAlive: true }
          },
          {
            path: '/order/dealViolation',
            name: 'DealViolation',
            component: () => import('@/views/tmall/order/dealViolation'),
            meta: { title: '违规处理', keepAlive: true }
          },
          {
            path: '/order/saleWaring',
            name: 'SaleWaring',
            component: () => import('@/views/tmall/order/saleWaring'),
            meta: { title: '售卖预警', keepAlive: true }
          }
        ]
      },
      {
        path: '/afterSale',
        name: 'AfterSale',
        component: RouteView,
        redirect: '/afterSale/afterSaleWorkbench',
        meta: { title: '售后', icon: 'property-safety' },
        children: [
          // {
          //   path: '/afterSale/afterSaleWorkbench',
          //   name: 'AfterSaleWorkbench',
          //   component: () => import('@/views/tmall/afterSale/afterSaleWorkbench'),
          //   meta: { title: '售后工作台', keepAlive: true }
          // },
          {
            path: '/afterSale/refund1',
            name: 'Refund1',
            component: () => import('@/views/tmall/afterSale/refund1'),
            meta: { title: '未发货退款', keepAlive: true }
          },
          {
            path: '/afterSale/refund2',
            name: 'Refund2',
            component: () => import('@/views/tmall/afterSale/refund2'),
            meta: { title: '已发货退款', keepAlive: true }
          },
          {
            path: '/afterSale/serverRequest',
            name: 'ServerRequest',
            component: () => import('@/views/tmall/afterSale/serverRequest'),
            meta: { title: '服务请求', keepAlive: true }
          },
          {
            path: '/afterSale/setConnect',
            name: 'SetConnect',
            component: () => import('@/views/tmall/afterSale/setConnect'),
            meta: { title: '客服电话设置', keepAlive: true }
          },
          {
            path: '/afterSale/refundHelper',
            name: 'RefundHelper',
            component: () => import('@/views/tmall/afterSale/refundHelper'),
            meta: { title: '极速退助手', keepAlive: true }
          }
        ]
      },
      {
        path: '/express',
        name: 'Express',
        component: RouteView,
        redirect: '/express/template',
        meta: { title: '物流', icon: 'car' },
        children: [
          {
            path: '/express/template',
            name: 'Template',
            component: () => import('@/views/tmall/express/template'),
            meta: { title: '运费模板', keepAlive: true }
          },
          {
            path: '/express/manageServer',
            name: 'ManageServer',
            component: () => import('@/views/tmall/express/manageServer'),
            meta: { title: '服务商管理', keepAlive: true }
          },
          {
            path: '/express/manageAddress',
            name: 'ManageAddress',
            component: () => import('@/views/tmall/express/manageAddress'),
            meta: { title: '地址库管理', keepAlive: true }
          },
          {
            path: '/express/manageServerAddress',
            name: 'ManageServerAddress',
            component: () => import('@/views/tmall/express/manageServerAddress'),
            meta: { title: '服务商地址', keepAlive: true }
          }
        ]
      },
      {
        path: '/data',
        name: 'Data',
        component: RouteView,
        redirect: '/data/coreData',
        meta: { title: '数据', icon: 'line-chart' },
        children: [
          {
            path: '/data/coreData',
            name: 'CoreData',
            component: () => import('@/views/tmall/data/coreData'),
            meta: { title: '核心数据', keepAlive: true }
          },
          {
            path: '/data/productAnalyze',
            name: 'ProductAnalyze',
            component: () => import('@/views/tmall/data/productAnalyze'),
            meta: { title: '商品分析', keepAlive: true }
          },
          {
            path: '/data/contentAnalyze',
            name: 'ContentAnalyze',
            component: () => import('@/views/tmall/data/contentAnalyze'),
            meta: { title: '内容分析', keepAlive: true }
          },
          {
            path: '/data/serviceAnalyze',
            name: 'ServiceAnalyze',
            component: () => import('@/views/tmall/data/serviceAnalyze'),
            meta: { title: '服务数据', keepAlive: true }
          },
          {
            path: '/data/dsrData',
            name: 'DsrData',
            component: () => import('@/views/tmall/data/dsrData'),
            meta: { title: 'DSR数据', keepAlive: true }
          }
        ]
      },
      {
        path: '/store',
        name: 'Store',
        component: RouteView,
        redirect: '/store/storeInfo',
        meta: { title: '店铺', icon: 'shop' },
        children: [
          {
            path: '/store/storeInfo',
            name: 'StoreInfo',
            component: () => import('@/views/tmall/store/storeInfo'),
            meta: { title: '店铺基本信息', keepAlive: true }
          },
          {
            path: '/store/storeDecorate',
            name: 'StoreDecorate',
            component: () => import('@/views/tmall/store/storeDecorate'),
            meta: { title: '店铺装修', keepAlive: true }
          }
        ]
      },
      {
        path: '/marketTools',
        name: 'MarketTools',
        component: RouteView,
        redirect: '/marketTools/shopCoupon',
        meta: { title: '营销工具', icon: 'copy' },
        children: [
          {
            path: '/marketTools/shopCoupon',
            name: 'ShopCoupon',
            component: () => import('@/views/tmall/marketTools/shopCoupon'),
            meta: { title: '优惠券', keepAlive: true }
          },
          {
            path: '/marketTools/timingSales',
            name: 'TimingSales',
            component: () => import('@/views/tmall/marketTools/timingSales'),
            meta: { title: '定时开售', keepAlive: true }
          },
          {
            path: '/marketTools/limitSales',
            name: 'LimitSales',
            component: () => import('@/views/tmall/marketTools/limitSales'),
            meta: { title: '限时特卖', keepAlive: true }
          },
          {
            path: '/marketTools/moneyOff',
            name: 'MoneyOff',
            component: () => import('@/views/tmall/marketTools/moneyOff'),
            meta: { title: '满减', keepAlive: true }
          }
        ]
      },
      {
        path: '/advertising',
        name: 'Advertising',
        component: RouteView,
        redirect: '/advertising/adCombine',
        meta: { title: '广告投放', icon: 'book' },
        children: [
          // {
          //   path: '/advertising/adCombine',
          //   name: 'AdCombine',
          //   component: () => import('@/views/tmall/advertising/adCombine'),
          //   meta: { title: '广告落地页', keepAlive: true }
          // },
          {
            path: '/advertising/score',
            name: 'Score',
            component: () => import('@/views/tmall/advertising/score'),
            meta: { title: '服务指标', keepAlive: true }
          }
          // ,
          // {
          //   path: '/advertising/qualification',
          //   name: 'Qualification',
          //   component: () => import('@/views/tmall/advertising/qualification'),
          //   meta: { title: '广告资质', keepAlive: true }
          // }
        ]
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  },
  {
    hidden: true,
    path: '/product/productH5',
    name: 'ProductH5',
    component: () => import('@/views/tmall/product/productH5'),
    meta: { title: '商品H5', keepAlive: true }
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: LoginLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/tmall/login/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
